<?php

namespace Index\Controller;

class PublicController extends CommonController {


    public function regist(){



        $this->display('Index/regist');
    }

    public function login(){


        $this->display('Index/login');
    }


    public function dologin(){
        $user = I('post.username');
        $pass = I('post.password');
        if(empty($user) || empty($pass)){
            $this->error('用户名或密码不能为空');exit;
        }
        $Pass = new \Common\Model\MemberPamModel();
        $info = $Pass->login($username);
        $pass = genSecretStr($pass,$info['password_account']);
        if($info['login_password'] === $pass){
            $info = $Pass->login($username);
            $pass = genSecretStr($pass,$info['password_account']);
            if($info['login_password'] === $pass){
                session('_id',$info['member_id']);
                session('_info',$info);
                $this->success('登陆成功');exit;
            }
        }
        $this->error('用户名或密码错误');

    }



    public function logout(){
        unset($this->_id,$this->_Info,$_SESSION);
        session_destroy();
        $this->redirect('Index/index');
    }

    public function getVerify(){
        $config = array(
            'useImgBg'=>TRUE,
            'imageH'=>18,
            'imageW'=>66,
            'length'=>6,
            'useZh'     =>  false
        );
        $verify = new \Think\Verify($config);

    }

}
